package com.top.vueservice.entities.mongo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;


//@CompoundIndex(def = "{'strname':1}") 复合索引  推荐用mongo命令行去建
@Document("myuser")//可以省略，如省略则默认以类名小写 映射集合
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MyUser {
    //主键标识，该属性会自动对应mongodb的主键"_id",如果该主键名叫id 则该注解可省略，否则必须写
    @Id
    private String id;
    //对应mongodb字段名字，如一致 无需注解
    @Field("strname")
    //@Indexed 单字段创建索引
    private String strName;

}
